﻿<cfsilent>
	<cfscript>
	
		dictAdvice = getProperty("serviceFactory").getBean("senateDictionaryAdvice");

		event.setArg("pageTitle", "教学运行管理 - 考试安排 - 学院课程补考安排");
		
		termId = event.getArg("TermID");
		depId = event.getArg("DepID");

		academicYear = event.getArg("AcademicYear");
		academicTerm = event.getArg("AcademicTerm");
		
		currentTab = event.getArg("TabID", "labToArrange");
		
		targetArgs = structNew();
		structInsert(targetArgs, "DepID", depId);
		
		passArgs = structNew();
		structInsert(passArgs, "InstituteID", depId);
		structInsert(passArgs, "TermID", termId);
		
		passDelArgs = structNew();
		structInsert(passDelArgs, "InstituteID", depId);
		
		
		/* 学院尚未安排考试课程设置 */
						
		sql = "SELECT 
				a.task_type, b.course_name, b.course_credit,  
				count(*) plan_count, 
				a.cid 
				FROM t_resitplan a  
					INNER JOIN t_course b ON b.cid = a.cid 
				WHERE 
					a.term_id = :termId 
					AND 
					b.institute_id = :depId 
					AND 
					a.is_arrange = '0' 
				GROUP BY a.task_type, b.course_name, b.course_credit, a.cid  
				ORDER BY a.task_type, b.course_name ";
				
		queryObj = new Query( datasource=application.dnsSlave ) ;
   		queryObj.addParam( name="termId", value=termId, cfsqltype="cf_sql_char" );
		queryObj.addParam( name="depId", value=depId, cfsqltype="cf_sql_varchar" );
		
		rs_courseToDo= queryObj.execute( sql=sql ).getResult();

		/* 学院尚未安排考试课程设置 */
							
		sql = "SELECT 
				a.task_type, b.course_name, b.course_credit,  
				count(*) plan_count, 
				a.cid 
				FROM t_resitplan a  
					INNER JOIN t_course b ON b.cid = a.cid 
				WHERE 
					a.term_id = :termId 
					AND 
					b.institute_id = :depId 
					AND 
					a.is_arrange = 'N' 
				GROUP BY a.task_type, b.course_name, b.course_credit, a.cid  
				ORDER BY a.task_type, b.course_name ";
				
		queryObj = new Query( datasource=application.dnsSlave ) ;
   		queryObj.addParam( name="termId", value=termId, cfsqltype="cf_sql_char" );
		queryObj.addParam( name="depId", value=depId, cfsqltype="cf_sql_varchar" );
		
		rs_courseNo= queryObj.execute( sql=sql ).getResult();
		
		/* 学院已安排的考试任务 */
				
		sql = "SELECT 
				b.course_name, 
				a.rstidx, 
				a.wid, 
				c.campus_id,
				a.wdidx, 
				a.cellidx, 
				a.task_exrstid
				FROM t_resittask a 
					 INNER JOIN t_course b ON b.cid = a.cid 
					 INNER JOIN t_campus c ON c.campus_id = a.campus_id 
				WHERE 
					a.term_id = :termId 
					AND 
					b.institute_id = :depId 
				ORDER BY b.course_name, a.rstidx";

		queryObj = new Query( datasource=application.dnsSlave ) ;
   		queryObj.addParam( name="termId", value=termId, cfsqltype="cf_sql_char" );
		queryObj.addParam( name="depId", value=depId, cfsqltype="cf_sql_varchar" );
		
		rs_courseDone= queryObj.execute( sql=sql ).getResult();
		
		/* 更新显示标签逻辑 */
		if ( currentTab eq "labToArrange" and rs_courseToDo.recordCount eq 0 and rs_courseNo.recordCount gt 0 ) {
			currentTab = "labNoArrange";
		}
		
		if ( currentTab eq "labToArrange" and rs_courseToDo.recordCount eq 0 and rs_courseNo.recordCount eq 0 and rs_courseDone.recordCount gt 0 ) {
			currentTab = "labDoneArrange";
		}

	</cfscript>
</cfsilent>

<div id="headArea">
	<div class="uiHeader uiHeaderWithImage ptm">
		<div class="clearfix uiHeaderTop">
			<div class="uiHeaderActions rfloat">
				<a class="uiButton" href="<cfoutput>#buildURL('examResitPlan')#</cfoutput>"><i class="mrs img btnList"></i><span class="uiButtonText">补考课程设置</span></a>
			</div>
			<div>
				<h2 class="uiHeaderTitle">
					<i class="uiHeaderImage img icon16x16 campus"></i>学院课程补考安排
				</h2>
			</div>
		</div>
	</div>
</div>

<div class="UIElement">
	<ul class="senateFirstPage">
		<li>
			<div class="clearfix">
			
				<div class="UItab">
					<div class="tabLables">
						<span <cfif currentTab eq "labToArrange">class="active"</cfif> id="labToArrange" tabTarget="ToArrange">尚未安排</span>
						<cfif rs_courseNo.recordCount>
							<span <cfif currentTab eq "labNoArrange">class="active"</cfif> id="labNoArrange" tabTarget="NoArrange">不考试课程</span>
						</cfif>
						<cfif rs_courseDone.recordCount>
							<span <cfif currentTab eq "labDoneArrange">class="active"</cfif> id="labDoneArrange" tabTarget="DoneArrange">考试周次及分组</span>
						</cfif>
					</div>
				</div>
				<script language="javascript" type="text/javascript">
					//<![CDATA[
					<!--
					$(document).ready(function() {
						
						/* init Tab */
						$("div.tabContent").hide();
						$("div#" + $("div.tabLables span.active").attr("tabTarget")).show();
						
						$("div.tabLables > span").click(function(){
							var $targetID = $(this).attr("tabTarget");
							
							$("div.tabLables span").removeClass("active");
							$(this).addClass("active");
							
							$("div.tabContent").not('[id="' + $targetID + '"]').hide();
							$("div.tabContent#" + $targetID).show();
						});
						
					});
					// -->
					//]]>
				</script>
				
				<div id="ToArrange" class="tabContent">
					
					<div class="noticeBlock">
						<div class="operation">
						</div>
						<h3>等待安排补考周次</h3>
						<p><span class="img icon16x16 message"></span><em><cfoutput>#academicYear#</cfoutput>-<cfoutput>#academicTerm#</cfoutput></em>学期, 有<em><cfoutput>#rs_courseToDo.recordCount#</cfoutput></em>门课程等待安排补考时间</p>
						<hr/>
					</div>
					
					<cfif rs_courseToDo.recordCount>
						<cfset row = 0 />
						<table class="UIEditable">
							<thead>
								<tr>
									<td width="18"></td>
									<!---<td width="18"></td>--->
									<td>开课类别</td>
									<td>课程</td>
									<td width="50">教学班</td>
									<td width="30">学分</td>
									<td width="18"></td>
								</tr>
							</thead>
							<tbody>
                                <cfloop query="rs_courseToDo"  >
									<cfset row++ />
									<cfset structInsert(targetArgs, "CID", rs_courseToDo.cid, true) />
									<cfset structInsert(targetArgs, "TT", rs_courseToDo.task_type, true) />
									
									<cfset structInsert(passArgs, "CourseID", rs_courseToDo.cid, true) />
									<cfset structInsert(passArgs, "TaskType", rs_courseToDo.task_type, true) />

									<tr class="editRows">
										<td><a title="该门课程不考试" href="<cfoutput>#buildURL('examResitCourseRemoveDo', passArgs)#</cfoutput>" class="stat remove"></a></td>
										<td><cfoutput>#dictAdvice.getTaskType(rs_courseToDo.task_type)#</cfoutput></td>
										<td><cfoutput>#rs_courseToDo.course_name#</cfoutput></td>
										<td align="center"><span class="numeric"><cfoutput>#rs_courseToDo.plan_count#</cfoutput></span></td>
										<td><span class="numeric"><cfoutput>#numberFormat(rs_courseToDo.course_credit, "_.__")#</cfoutput></span></td>
										<td><a title="安排课程考试周次与分组" href="<cfoutput>#buildURL('examResitByCourse', targetArgs)#</cfoutput>" class="stat edit"></a></td>
									</tr>
								</cfloop>
							</tbody>
						</table>
						
					</cfif>
					
					
				</div>
				
				<cfif rs_courseNo.recordCount>
					
					<div id="NoArrange" class="tabContent">
						
						<div class="noticeBlock">
							<h3>不安排考试</h3>
							<p><span class="img icon16x16 message"></span><em><cfoutput>#academicYear#</cfoutput>-<cfoutput>#academicTerm#</cfoutput></em>学期, 有<em><cfoutput>#rs_courseNo.recordCount#</cfoutput></em>门课程已标注为不需要安排补考时间</p>
							<hr/>
						</div>
						
						<cfset row = 0 />
						<table class="UIEditable">
							<thead>
								<tr>
									<td width="18"></td>
									<td>开课类别</td>
									<td>课程</td>
									<td width="50">教学班</td>
									<td width="30">学分</td>
								</tr>
							</thead>
							<tbody>
                                <cfloop query="rs_courseNo" >
									<cfset row++ />
									
									<cfset structInsert(passArgs, "CourseID", rs_courseNo.cid, true) />
									<cfset structInsert(passArgs, "TaskType", rs_courseNo.task_type, true) />

									<tr class="editRows">
										<td><a title="恢复该门课程考试安排" href="<cfoutput>#buildURL('examResitCourseRestoreDo', passArgs)#</cfoutput>" class="stat restore"></a></td>
										<td><cfoutput>#dictAdvice.getTaskType(rs_courseNo.task_type)#</cfoutput></td>
										<td><cfoutput>#rs_courseNo.course_name#</cfoutput></td>
										<td align="center"><span class="numeric"><cfoutput>#rs_courseNo.plan_count#</cfoutput></span></td>
										<td><span class="numeric"><cfoutput>#numberFormat(rs_courseNo.course_credit, "_.__")#</cfoutput></span></td>
									</tr>
								</cfloop>
							</tbody>
						</table>

					</div>
					
				</cfif>
				
				<cfif rs_courseDone.recordCount>
					
					<div id="DoneArrange" class="tabContent">
						
						<div class="noticeBlock">
							<h3>课程考试周次及分组安排</h3>
							<p><span class="img icon16x16 message"></span><em><cfoutput>#academicYear#</cfoutput>-<cfoutput>#academicTerm#</cfoutput></em>学期, 有<em><cfoutput>#rs_courseDone.recordCount#</cfoutput></em>场补考安排</p>
							<hr/>
						</div>
						
						<cfset row = 0 />
						<table class="UIEditable">
							<thead>
								<tr>
									<td width="40">场次</td>
									<td>课程</td>
									<td width="60">考试校区</td>
									<td width="50">考试周</td>
									<td>考试时间</td>
									<td width="18"></td>
								</tr>
							</thead>
							<tbody>
                                <cfloop query="rs_courseDone" >
									<cfset row++ />
									<cfset structInsert(passDelArgs, "TaskExamID", rs_courseDone.task_exrstid, true) />

									<tr class="editRows">
										<td class="index"><cfoutput>#rs_courseDone.rstidx#</cfoutput></td>
										<td><cfoutput>#rs_courseDone.course_name#</cfoutput></td>
										<td><cfoutput>#rs_courseDone.campus_id#</cfoutput></td>
										<td align="center"><span class="numeric"><cfoutput>#rs_courseDone.wid#</cfoutput></span></td>
										<td><cfif rs_courseDone.wdidx eq "0">-/-<cfelse>星期<span class="numeric"><cfoutput>#rs_courseDone.wdidx#</cfoutput></span>第<span class="numeric"><cfoutput>#rs_courseDone.cellidx#</cfoutput></span>场</cfif></td>
										<td>
											<cfif rs_courseDone.wdidx eq "0">
												<a title="删除补考任务" href="<cfoutput>#buildURL('examResitTaskByDepartmentRemoveDo', passDelArgs)#</cfoutput>" class="stat delete"></a>
												<cfelse>
												<span class="stat locked"></span>
											</cfif>
										</td>
									</tr>
								</cfloop>
							</tbody>
						</table>
						
					</div>
					
				</cfif>
				
			
			</div>
		</li>
	</ul>
</div>
			
			
